#-*- coding-8 -*-
import smtplib
from email.mime.text import MIMEText
from email.header import Header

smtp_server = "smtp.qq.com"
smtp_port = 465
smtp_username = "simon4055@foxmail.com"
smtp_password = "这里写授权码"

def sendmail(sender, receivers, Subject, Content, sendername):
    mail = MIMEText(Content, "plain", "utf-8")
    mail["From"] = Header(sendername, "utf-8")
    mail["Subject"] = Subject
    try:
        server = smtplib.SMTP_SSL(smtp_server, smtp_port)
        server.login(smtp_username, smtp_password)
        server.sendmail(sender, receivers, mail.as_string())
        server.quit()
    except smtplib.SMTPException as E:
        print("发送邮件失败！异常信息：", E)

if __name__ == "__main__":
    sendmail("simon4055@foxmail.com", ["simon4055@foxmail.com", "56343418@qq.com"], "一起来学Python", "学Python，发送邮件测试...", "合肥吃货食光")